package com.lie.prepare.multi_thread.queue;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * Created by lie on 2018/4/9.
 */
public class ToastTest {

    public static void main(String[] args) throws InterruptedException {
        ToastQueue dryQueue = new ToastQueue();
        ToastQueue butterQueue = new ToastQueue();
        ToastQueue finishedQueue = new ToastQueue();

        ExecutorService executor = Executors.newCachedThreadPool();
        executor.execute(new Toaster(dryQueue));
        executor.execute(new Butterer(dryQueue, butterQueue));
        executor.execute(new Jammer(butterQueue, finishedQueue));
        executor.execute(new ToastConsumer(finishedQueue));

        TimeUnit.SECONDS.sleep(2);
        executor.shutdownNow();

    }
}
